<!-- 页面外套 -->
<div class="page-wrapper" id="setup_business_return">

    <!-- 工具条组 -->
    <div class="tool-group">
        <table class="table table-bordered">
            <thead>
                <tr>
                    <th style="width:100px;">类型</th>
                    <th style="width:100px;">等级</th>
                    <th style="width:100px;">天数</th>
                    <th>操作</th>
                </tr>
            </thead>
            <tbody><!-- JS推进 --></tbody>
        </table>
    </div>
    <!-- tool-group -->
 
    <!-- 修改盒子(业务正跟踪) -->
    <div class="modal modal-for-page fade" aria-hidden="false" id="setup_business_return_edit1_box">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">关闭</span></button>
                    <h4 class="modal-title">修改</h4>
                </div>
                <div class="modal-body">
                    <form class="container form-horizontal">
                        <div class="form-group require">
                            <label class="col-sm-3"></label>
                            <div class="col-sm-8">
                                <div class="input-group input-short">
                                    <input type="number" class="form-control" id="setup_business_return_edit1_day">
                                    <span class="input-group-addon">天</span>
                                </div>
                            </div>
                        </div>
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <button type="button" class="btn btn-primary" id="setup_business_return_edit1_submit">提交</button>
                </div>
            </div>
        </div>
    </div>
    <!-- setup_business_return_edit1_box -->

    <!-- 修改盒子(通用) -->
    <div class="modal modal-for-page fade" aria-hidden="false" id="setup_business_return_edits_box">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">关闭</span></button>
                    <h4 class="modal-title">信息员修改</h4>
                </div>
                <div class="modal-body">
                    <form class="container form-horizontal">
                        <div class="form-group require">
                            <label class="col-sm-3">A</label>
                            <div class="col-sm-8">
                                <div class="input-group input-short">
                                    <input type="number" class="form-control" id="setup_business_return_edits_daya">
                                    <span class="input-group-addon">天</span>
                                </div>
                            </div>
                        </div>
                        <div class="form-group require">
                            <label class="col-sm-3">B</label>
                            <div class="col-sm-8">
                                <div class="input-group input-short">
                                    <input type="number" class="form-control" id="setup_business_return_edits_dayb">
                                    <span class="input-group-addon">天</span>
                                </div>
                            </div>
                        </div>                        
                        <div class="form-group require">
                            <label class="col-sm-3">C</label>
                            <div class="col-sm-8">
                                <div class="input-group input-short">
                                    <input type="number" class="form-control" id="setup_business_return_edits_dayc">
                                    <span class="input-group-addon">天</span>
                                </div>
                            </div>
                        </div>
                        <div class="form-group require">
                            <label class="col-sm-3">D</label>
                            <div class="col-sm-8">
                                <div class="input-group input-short">
                                    <input type="number" class="form-control" id="setup_business_return_edits_dayd">
                                    <span class="input-group-addon">天</span>
                                </div>
                            </div>
                        </div>
                        <div class="form-group require">
                            <label class="col-sm-3">E</label>
                            <div class="col-sm-8">
                                <div class="input-group input-short">
                                    <input type="number" class="form-control" id="setup_business_return_edits_daye">
                                    <span class="input-group-addon">天</span>
                                </div>
                            </div>
                        </div>
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <button type="button" class="btn btn-primary" id="setup_business_return_edits_submit">提交</button>
                </div>
            </div>
        </div>
    </div>
    <!-- setup_business_return_edits_box -->    

</div>
<!-- page-wrapper -->

<script>
$(function(){
   
    //变量声明-----------------------------------------------------------------------------------------------
    var
    setup_business_return               = $("#setup_business_return"),              //页面ID
    //修改盒子(业务正跟踪)
    setup_business_return_edit1_box     = $("#setup_business_return_edit1_box"),    //修改盒子
    setup_business_return_edit1_submit  = $("#setup_business_return_edit1_submit"), //修改提交
    setup_business_return_edit1_day     = $("#setup_business_return_edit1_day"),    //修改天数
    //修改盒子(通用)
    setup_business_return_edits_box     = $("#setup_business_return_edits_box"),    //修改盒子
    setup_business_return_edits_submit  = $("#setup_business_return_edits_submit"), //修改提交
    setup_business_return_edits_daya    = $("#setup_business_return_edits_daya"),   //等级A天数
    setup_business_return_edits_dayb    = $("#setup_business_return_edits_dayb"),   //等级B天数
    setup_business_return_edits_dayc    = $("#setup_business_return_edits_dayc"),   //等级C天数
    setup_business_return_edits_dayd    = $("#setup_business_return_edits_dayd"),   //等级D天数
    setup_business_return_edits_daye    = $("#setup_business_return_edits_daye");   //等级E天数

    //接口对象-----------------------------------------------------------------------------------------------
    if( window.STATE == "local" ){

        //本地接口
        var setup_business_return_api = {
            modal_edit : LOCAL + "Test/Setup/Business/return_edit.json",           //修改盒子
        }

    } else if ( window.STATE == "route" ){

        //远程接口
        var setup_business_return_api = {
            modal_edit : LOCAL + "Test/Setup/Business/return_edit.json",           //修改盒子
        }

    }

    //数据表格调用-------------------------------------------------------------------------------------------
    setup_business_return_dataTable();

    //变量声明
    var
    setup_business_return_edit1_btn = ".setup_business_return_edit1_btn",    //业务正跟踪
    setup_business_return_edits_btn = ".setup_business_return_edits_btn";    //通用

    //修改按钮(业务正跟踪)-----------------------------------------------------------------------------------
    $(document).on("click",setup_business_return_edit1_btn,function(){

        //数据获取
        var data_type = $(this).attr("type");
        setup_business_return_edit1_submit.attr("type",data_type);

        //远程请求
        $.ajax({
            url     : setup_business_return_api.modal_edit,
            type    : "post",
            dataType: "json",
            data    : { type : data_type },
            success : function(data){
                if( data.status>0 ){
                    var data = data.data;
                    setup_business_return_edit1_day.val( data.provider[0] );
                    setup_business_return_edit1_box.modal("show");
                } else {
                    um_tip(data.message,"1500","text-danger");
                }
            }
        });

    });
    //修改提交
    setup_business_return_edit1_submit.click(function(){

        //数据获取
        var data_type = $(this).attr("type");

        //远程提交
        $.ajax({
            url     : API.test_response,
            type    : "post",
            dataType: "json",
            data    : {
                type : data_type,
                day  : setup_business_return_edit1_day.val(),
             },
            success : function(data){
                if( data.status>0 ){
                    um_tip(data.message);
                    setTimeout(function(){
                        setup_business_return_dataTable(); //数据表格刷新
                        setup_business_return_edit1_box.modal("hide"); 
                    },1500); 
                } else {
                    um_tip(data.message,"1500","text-danger");
                }
            }
        });

    });

    //修改按钮(通用)-----------------------------------------------------------------------------------------
    $(document).on("click",setup_business_return_edits_btn,function(){

        //数据获取
        var data_type = $(this).attr("type");
        setup_business_return_edits_submit.attr("type",data_type);

        //远程请求
        $.ajax({
            url     : setup_business_return_api.modal_edit,
            type    : "post",
            dataType: "json",
            data    : { type : data_type },
            success : function(data){
                if( data.status>0 ){
                    var data = data.data;
                    setup_business_return_edits_daya.val( data.provider[0] );
                    setup_business_return_edits_dayb.val( data.provider[1] );
                    setup_business_return_edits_dayc.val( data.provider[2] );
                    setup_business_return_edits_dayd.val( data.provider[3] );
                    setup_business_return_edits_daye.val( data.provider[4] );
                    setup_business_return_edits_box.modal("show");
                } else {
                    um_tip(data.message,"1500","text-danger");
                }
            }
        });

    });
    //修改提交
    setup_business_return_edits_submit.click(function(){

        //数据获取
        var data_type = $(this).attr("type");

        //远程提交
        $.ajax({
            url     : API.test_response,
            type    : "post",
            dataType: "json",
            data    : {
                type : data_type,
                a : setup_business_return_edits_daya.val(),
                b : setup_business_return_edits_dayb.val(),
                c : setup_business_return_edits_dayc.val(),
                d : setup_business_return_edits_dayd.val(),
                e : setup_business_return_edits_daye.val(),
             },
            success : function(data){
                if( data.status>0 ){
                    um_tip(data.message);
                    setTimeout(function(){
                        setup_business_return_dataTable(); //数据表格刷新
                        setup_business_return_edits_box.modal("hide"); 
                    },1500); 
                } else {
                    um_tip(data.message,"1500","text-danger");
                }
            }
        });

    });
 
    //数据表格声明-------------------------------------------------------------------------------------------
    function setup_business_return_dataTable() {
        $.ajax({
            url     : setup_business_return_api.modal_edit,
            type    : "post",
            dataType: "json",
            data    : { },
            success : function(data){
                if( data.status>0 ){

                    //数据赋值
                    var data = data.data;
                    var temp = `
                    <tr>
                        <td rowspan="5"><b>信息员</b></td><td>A</td>
                        <td>${data.provider[0]}</td><td rowspan="5"><a type="provider" class="setup_business_return_edits_btn">修改</a></td>
                    </tr>
                    <tr><td>B</td><td>${data.provider[1]}</td></tr>
                    <tr><td>C</td><td>${data.provider[2]}</td></tr>
                    <tr><td>D</td><td>${data.provider[3]}</td></tr>
                    <tr><td>E</td><td>${data.provider[4]}</td></tr>
                    <tr>
                        <td><b>业务正跟踪</b></td><td></td>
                        <td>${data.tracked[0]}</td><td><a type="tracked" class="setup_business_return_edit1_btn">修改</a></td>
                    </tr>
                    <tr>
                        <td rowspan="5"><b>业务在谈</b></td><td>A</td>
                        <td>${data.business[0]}</td><td rowspan="5"><a type="business" class="setup_business_return_edits_btn">修改</a></td>
                    </tr>
                    <tr><td>B</td><td>${data.business[1]}</td></tr>
                    <tr><td>C</td><td>${data.business[2]}</td></tr>
                    <tr><td>D</td><td>${data.business[3]}</td></tr>
                    <tr><td>E</td><td>${data.business[4]}</td></tr>
                    <tr>
                        <td rowspan="5"><b>设计在谈</b></td><td>A</td>
                        <td>${data.designer[0]}</td><td rowspan="5"><a type="designer" class="setup_business_return_edits_btn">修改</a></td>
                    </tr>
                    <tr><td>B</td><td>${data.designer[1]}</td></tr>
                    <tr><td>C</td><td>${data.designer[2]}</td></tr>
                    <tr><td>D</td><td>${data.designer[3]}</td></tr>
                    <tr><td>E</td><td>${data.designer[4]}</td></tr>
                    `;
                    setup_business_return.find("tbody").html(temp);

                } else {
                    um_tip(data.message,"1500","text-danger");
                }
            }
        });
    }

});//预加载结尾
</script>